home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d2 / sysreq.arc / SYSREQ.ASM < prev    next >
Assembly Source File  |  1988-04-16  |  4KB  |  112 lines

  1. ;******************************************************************************
  2. ;  SYSREQ    -  Turns the Sys-Req key on PC-AT's into a pause key.
  3. ;
  4. ;  Description    -  SYSREQ loads up an interrupt service routine to service
  5. ;           the interrupt that is generated when the Sys-Req key is
  6. ;           pressed on the PC-AT's keyboard  (interrupt 15H). The
  7. ;           first time the key is pressed the routine enters a
  8. ;           pause loop that is only exited when the key is pressed
  9. ;           a second time (i.e. press it once - pause; press it again -
  10. ;           continue).  The advantages to SYSREQ are 1) only one key
  11. ;           stroke to pause instead of two (Crtl-Num-Lock), and 2) it
  12. ;           doesn't need to filter all key stokes to determine when
  13. ;           the key is depressed, since the BIOS keyboard service
  14. ;           routine generates the interrupt when Sys-Req is pressed.
  15. ;           The disadvantage is that it only works on AT's.
  16. ;******************************************************************************
  17. ;=======EQUATES
  18. CLEAR_F         EQU    000H    ;Value of cleared flag.
  19. SET_F            EQU    001H    ;Value of set flag.
  20. SYS_REQ_INT        EQU    015H    ;Interrupt vector for Sys-Req key.
  21. DOS_FUNCTION        EQU    021H    ;DOS Function request interrupt.
  22. DISPLAY_STRING        EQU    009H    ;DOS Display string function.
  23. GET_VECTOR        EQU    035H    ;DOS Get vector address function.
  24. SET_VECTOR        EQU    025H    ;DOS Set vector address function.
  25. TERMINATE_RESIDENT    EQU    027H    ;DOS Terminate but stay resident int.
  26. BIOS_DATA        EQU    00040H    ;Base segment of BIOS data area.
  27. CRT_MODE        EQU    00049H    ;Offset of CRT_MODE byte in BIOS data.
  28. CRT_MODE_SET        EQU    00065H    ;Offset of CRT_MODE_SET byte.
  29. CRT_CONTROL        EQU    003D8H    ;Address of crt control port.
  30.  
  31. ;=======CODE
  32. CSEG    SEGMENT PARA    PUBLIC    'CODE'
  33.     ORG    00100H
  34.     ASSUME    CS:CSEG,DS:CSEG
  35.  
  36. START:    JMP    SHORT INITIALIZE    ;Initialize variables.
  37.  
  38. OLD_INT  LABEL    DWORD            ;Space for old interrupt vector
  39. OLD_INT_IP    DW    ?        ;  Instruction pointer
  40. OLD_INT_CS    DW    ?        ;  Code segment
  41. PAUSE_ACTIVE    DB    CLEAR_F     ;Pause active flag
  42.  
  43. NEW_INT PROC   FAR            ;Interrupt service routine entry point.
  44.     ASSUME    DS:NOTHING
  45.  
  46.     STI                ;Turn interrupts back on.
  47.     CMP    AX, 08500H        ;Is Sys-Req key pushed down?
  48.     JE    SYS_REQ_MAKE        ; Yes: Service pause request.
  49.     CMP    AX, 08501H        ;Is Sys-Req key let up?
  50.     JE    EXIT_INT        ; Yes: Ignore it and exit.
  51.     JMP    CS:OLD_INT        ;If not Sys-Req key, do old interrupt.
  52.  
  53. SYS_REQ_MAKE:
  54.     CMP    CS:PAUSE_ACTIVE, SET_F    ;Is pause currently active?
  55.     JE    QUIT_PAUSE        ; Yes: Reset pause flag and exit.
  56.     MOV    CS:PAUSE_ACTIVE, SET_F    ; No: Set pause flag.
  57.     PUSH    DS            ;Save data segment
  58.     PUSH    BX            ;Save BX
  59.     MOV    AX, BIOS_DATA        ;Point to ...
  60.     MOV    DS, AX            ;     ... BIOS data area base.
  61.     MOV    BX, CRT_MODE        ;Point to current video mode.
  62.     MOV    AL, [BX]        ;Get current video mode.
  63.     CMP    AL, 007H        ;Is it monochrome?
  64.     JAE    MONO            ; Yes: Then don't worry about it
  65.     MOV    BX, CRT_MODE_SET    ; No: point to video mode setting...
  66.     MOV    AL, [BX]        ;     and get it...
  67.     PUSH    DX            ;     and save DX...
  68.     MOV    DX, CRT_CONTROL     ;     and point to video controller...
  69.     OUT    DX, AL            ;     and turn video on...
  70.     POP    DX            ;     and restore DX.
  71.  
  72. MONO:    POP    BX            ;Restore BX.
  73.     POP    DS            ;Restore data segment.
  74.  
  75. WAIT_LOOP:
  76.     CMP    CS:PAUSE_ACTIVE, SET_F    ;Is pause flag set?
  77.     JE    WAIT_LOOP        ; Yes: Loop until it is cleared.
  78.     IRET                ; No:  Return from interrupt.
  79.  
  80. QUIT_PAUSE:
  81.     MOV    CS:PAUSE_ACTIVE,CLEAR_F ;Clear pause flag.
  82. EXIT_INT:
  83.     IRET                ;Exit interrupt.
  84.  
  85. NEW_INT ENDP                ;End of interrupt service routine.
  86.  
  87. INITIALIZE:
  88.     ASSUME    DS:CSEG
  89.     MOV    AL, SYS_REQ_INT
  90.     MOV    AH, GET_VECTOR
  91.     INT    DOS_FUNCTION        ;Get old interrupt vector
  92.     MOV    OLD_INT_IP, BX        ;  save instruction pointer
  93.     MOV    OLD_INT_CS, ES        ;  save code segment
  94.  
  95.  
  96.     MOV    DX, OFFSET NEW_INT    ;New interrupt instruction pointer
  97.     MOV    AL, SYS_REQ_INT
  98.     MOV    AH, SET_VECTOR
  99.     INT    DOS_FUNCTION        ;Set new interrupt address
  100.  
  101.     MOV    DX, OFFSET MESSAGE    ;Output message...
  102.     MOV    AH, DISPLAY_STRING    ; to the standard...
  103.     INT    DOS_FUNCTION        ;  output device.
  104.  
  105.     MOV    DX, OFFSET INITIALIZE    ;End of ISR code
  106.     INT    TERMINATE_RESIDENT    ;Terminate but leave ISR resident.
  107.  
  108. MESSAGE DB    00DH,00AH,'Sys-Req key pause routine installed.',00DH,00AH,'$'
  109.  
  110. CSEG    ENDS
  111.     END    START
  112.